library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ forcats   1.0.0     ✔ readr     2.1.5
## ✔ ggplot2   3.4.4     ✔ stringr   1.5.1
## ✔ lubridate 1.9.3     ✔ tibble    3.2.1
## ✔ purrr     1.0.2     ✔ tidyr     1.3.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(ggplot2)
library(sf)
## Linking to GEOS 3.11.0, GDAL 3.5.3, PROJ 9.1.0; sf_use_s2() is TRUE
library(mapview)
starbucks <- read.csv("All_Starbucks_Locations_in_the_US_-_Map.csv")
starbucks
#Which starbucks location has ownership type and which doesn’t depending on it's resident state
data <- starbucks%>%
  group_by(Ownership.Type)%>%
  select(Features...Stations, Ownership.Type, State, Latitude, Longitude) 
NewData <- head(data, 50)
NewData
#Determine how many ownership types are present in the data set
NewData%>%
count(Ownership.Type)
#create one interactive plot
#This particular plot shows if the state have drive through or don't
ggplot(data = NewData, mapping = aes(x = Ownership.Type, y = State, color = Features...Stations)) + geom_point()

#creating one spatial visualization plot to view the Starbucks locations in Florida
FloridaStarbucks <- starbucks%>%
  group_by(State)%>%
  select(Features...Stations, Zip, Ownership.Type, State, Latitude, Longitude)%>%
  filter(State == "FL")
NewData2 <- head(FloridaStarbucks, 50)
NewData2
myview <- mapview(NewData2, xcol = "Longitude", ycol = "Latitude", crs = 4269, grid = FALSE)
myview
#creating one visualization of a model to see how far each starbucks zip codes are from each other
NewData3 <- head(NewData2, 40)
NewData3
newdata <- separate(NewData3, Zip, "NewZip")
## Warning: Expected 1 pieces. Additional pieces discarded in 36 rows [1, 3, 4, 6, 7, 8, 9,
## 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, ...].
linear_model <- lm(NewZip ~ Longitude + Latitude, data = newdata) 
plot(linear_model)